<!DOCTYPE html>
<html class="writer-html4" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>p4utils.utils.sswitch_p4runtime_API module &mdash; P4-Utils 1.0 documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
      <script>
          var DOCUMENTATION_OPTIONS = {
              URL_ROOT:'./',
              VERSION:'1.0',
              LANGUAGE:'None',
              COLLAPSE_INDEX:false,
              FILE_SUFFIX:'.html',
              HAS_SOURCE:  false,
              SOURCELINK_SUFFIX: '.txt'
          };
      </script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="p4utils.utils.sswitch_thrift_API module" href="p4utils.utils.sswitch_thrift_API.html" />
    <link rel="prev" title="p4utils.utils.monitor module" href="p4utils.utils.monitor.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
            <a href="index.html" class="icon icon-home"> P4-Utils
          </a>
              <div class="version">
                1.0
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption"><span class="caption-text">General Documentation</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage.html">Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="advanced_usage.html">Advanced Usage</a></li>
</ul>
<p class="caption"><span class="caption-text">API Reference</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="p4utils.html">P4-Utils API reference</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="p4utils.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="p4utils.mininetlib.html">p4utils.mininetlib package</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="p4utils.utils.html">p4utils.utils package</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="p4utils.utils.html#subpackages">Subpackages</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="p4utils.utils.html#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="p4utils.utils.html#module-p4utils.utils">Module contents</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="p4utils.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="p4utils.html#module-p4utils">Module contents</a></li>
</ul>
</li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">P4-Utils</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
          <li><a href="p4utils.html">P4-Utils API reference</a> &raquo;</li>
          <li><a href="p4utils.utils.html">p4utils.utils package</a> &raquo;</li>
      <li>p4utils.utils.sswitch_p4runtime_API module</li>
      <li class="wy-breadcrumbs-aside">
              <a href="https://github.com/nsg-ethz/p4-utils/blob/master/docs/source/p4utils.utils.sswitch_p4runtime_API.rst" class="fa fa-github"> Edit on GitHub</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <div class="section" id="module-p4utils.utils.sswitch_p4runtime_API">
<span id="p4utils-utils-sswitch-p4runtime-api-module"></span><h1>p4utils.utils.sswitch_p4runtime_API module<a class="headerlink" href="#module-p4utils.utils.sswitch_p4runtime_API" title="Permalink to this headline">¶</a></h1>
<p>This module provides a <em>P4Runtime API</em> for the <em>Simple Switch</em> target. It builds
on the generic <a class="reference external" href="p4utils.utils.p4runtime_API.html">P4Runtime API</a>. The methods listed here were designed to be as
close as possible (in the naming and in the signature) to those used in the
<a class="reference internal" href="p4utils.utils.thrift_API.html#p4utils.utils.thrift_API.ThriftAPI" title="p4utils.utils.thrift_API.ThriftAPI"><code class="xref py py-class docutils literal"><span class="pre">ThriftAPI</span></code></a>, so that passing to one method to the
other is easier for the user.</p>
<dl class="class">
<dt id="p4utils.utils.sswitch_p4runtime_API.CounterType">
<em class="property">class </em><code class="descclassname">p4utils.utils.sswitch_p4runtime_API.</code><code class="descname">CounterType</code><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L21-L29"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.CounterType" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/enum.html#enum.Enum" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">enum.Enum</span></code></a></p>
<p>Counter type according to <em>P4 Runtime Specification</em>. See <a class="reference external" href="https://github.com/p4lang/p4runtime/blob/57bb925a30df02b5c492c2a16c29b0014b98fa7a/proto/p4/config/v1/p4info.proto#L278">here</a> for details.</p>
<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.CounterType.both">
<code class="descname">both</code><em class="property"> = 3</em><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.CounterType.both" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.CounterType.bytes">
<code class="descname">bytes</code><em class="property"> = 1</em><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.CounterType.bytes" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.CounterType.packets">
<code class="descname">packets</code><em class="property"> = 2</em><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.CounterType.packets" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.CounterType.unspecified">
<code class="descname">unspecified</code><em class="property"> = 0</em><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.CounterType.unspecified" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI">
<em class="property">class </em><code class="descclassname">p4utils.utils.sswitch_p4runtime_API.</code><code class="descname">SimpleSwitchP4RuntimeAPI</code><span class="sig-paren">(</span><em>device_id</em>, <em>grpc_port</em>, <em>grpc_ip='0.0.0.0'</em>, <em>p4rt_path=None</em>, <em>json_path=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L47-L1361"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>For a better documentation of the primitives and the assumptions used,
please take a look at:</p>
<ul class="simple">
<li><a class="reference external" href="p4utils.utils.p4runtime_API.html">P4Runtime API subpackage</a></li>
<li><a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html">P4Runtime specification</a></li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>device_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – switch <em>id</em></li>
<li><strong>grpc_port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the port the switch gRPC server is listening on</li>
<li><strong>grpc_ip</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the IP the switch gRPC server is listening on</li>
<li><strong>p4rt_path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – path to the P4Runtime Info file</li>
<li><strong>json_path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – path to the P4 JSON compiled file</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#FileNotFoundError" title="(in Python v3.10)"><code class="xref py py-exc docutils literal"><span class="pre">FileNotFoundError</span></code></a> – if <code class="docutils literal"><span class="pre">p4rt_path</span></code> or <code class="docutils literal"><span class="pre">json_path</span></code> are not specified, or invalid and
the client cannot retrieve the relevant informations from the
P4Runtime server.</p>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.client">
<code class="descname">client</code><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.client" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="p4utils.utils.p4runtime_API.p4runtime.html#p4utils.utils.p4runtime_API.p4runtime.P4RuntimeClient" title="p4utils.utils.p4runtime_API.p4runtime.P4RuntimeClient"><code class="xref py py-class docutils literal"><span class="pre">P4RuntimeClient</span></code></a> – P4Runtime client instance.</p>
</dd></dl>

<dl class="attribute">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.context">
<code class="descname">context</code><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.context" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="p4utils.utils.p4runtime_API.context.html#p4utils.utils.p4runtime_API.context.Context" title="p4utils.utils.p4runtime_API.context.Context"><code class="xref py py-class docutils literal"><span class="pre">Context</span></code></a> – P4Runtime context containing the information about all the P4 objects.</p>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_read">
<code class="descname">counter_read</code><span class="sig-paren">(</span><em>counter_name</em>, <em>index</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L763-L791"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_read" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads counter value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the counter</li>
<li><strong>index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – index of the counter to read (first element is at <code class="docutils literal"><span class="pre">0</span></code>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><p><code class="docutils literal"><span class="pre">(byte_count,</span> <span class="pre">packet_count)</span></code> where:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">byte_count</span></code> is the number of bytes counted;</li>
<li><code class="docutils literal"><span class="pre">packet_count</span></code> is the number of bytes counted.</li>
</ul>
</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)">tuple</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">P4Runtime does not distinguish between the different counter types, i.e. counters are
always considered of <strong>PACKETS_AND_BYTES</strong> and both values are returned. It is user’s responsability
to use only the correct value (see <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-counterentry-directcounterentry">here</a>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_reset">
<code class="descname">counter_reset</code><span class="sig-paren">(</span><em>counter_name</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L826-L846"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets all the counters values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the counter</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_write">
<code class="descname">counter_write</code><span class="sig-paren">(</span><em>counter_name</em>, <em>index</em>, <em>pkts=0</em>, <em>byts=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L793-L824"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.counter_write" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes counter values. If no values are specified, the counter is reset.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the counter</li>
<li><strong>index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – index of the counter to write (first element is at <code class="docutils literal"><span class="pre">0</span></code>)</li>
<li><strong>pkts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of packets to write (default: <code class="docutils literal"><span class="pre">0</span></code>)</li>
<li><strong>byts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of bytes to write (default: <code class="docutils literal"><span class="pre">0</span></code>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>There are three types of counters:</p>
<ul class="simple">
<li><strong>BYTES</strong>, only the field <code class="docutils literal"><span class="pre">byts</span></code> is written and the value of <code class="docutils literal"><span class="pre">pkts</span></code> is ignored.</li>
<li><strong>PACKETS</strong>, only the field <code class="docutils literal"><span class="pre">pkts</span></code> is written and the value of <code class="docutils literal"><span class="pre">byts</span></code> is ignored.</li>
<li><strong>PACKETS_AND_BYTES</strong>, both <code class="docutils literal"><span class="pre">byts</span></code> and <code class="docutils literal"><span class="pre">pkts</span></code> are written.</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_create">
<code class="descname">cs_create</code><span class="sig-paren">(</span><em>session_id</em>, <em>ports=[]</em>, <em>instances=None</em>, <em>cos=0</em>, <em>packet_length=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1097-L1146"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_create" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a packet cloning session.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>session_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – clone session <em>id</em></li>
<li><strong>ports</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of port numbers to add to the clone session
(each port number is <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>instances</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of instances of the corresponding ports
(each instance is <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>cos</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – Class of Service (see <a class="reference external" href="https://p4.org/p4-spec/docs/PSA-v1.1.0.html#sec-after-ingress">here</a>)</li>
<li><strong>packet_lentgth</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – maximal packet length in bytes (after which, packets are truncated)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group. Instances can be explicitly assigned to ports by
passing the list instances to this function. If the list instances is not
specified, then the instance number is set to <code class="docutils literal"><span class="pre">0</span></code> for all the replicas by default.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">By default, <code class="docutils literal"><span class="pre">packet_length</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code> i.e. no truncation happens and
<code class="docutils literal"><span class="pre">cos</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code> (normal packet classification). If <code class="docutils literal"><span class="pre">ports</span></code> is
an empty list, then the packets are not cloned to any port.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_destroy">
<code class="descname">cs_destroy</code><span class="sig-paren">(</span><em>session_id</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1148-L1161"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_destroy" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes a packet cloning session.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>session_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – clone session <em>id</em></td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_get_replicas">
<code class="descname">cs_get_replicas</code><span class="sig-paren">(</span><em>session_id</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1214-L1245"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_get_replicas" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets replicas which belog to a clone session.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>session_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – clone session id</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal"><span class="pre">(ports,</span> <span class="pre">instances)</span></code> where:<ul class="simple">
<li><code class="docutils literal"><span class="pre">ports</span></code> is a list of port numbers of the clone session;</li>
<li><code class="docutils literal"><span class="pre">instances</span></code> is a list of instances of the corresponding ports.</li>
</ul>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)">tuple</a></td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group.</p>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_set_replicas">
<code class="descname">cs_set_replicas</code><span class="sig-paren">(</span><em>session_id</em>, <em>ports=[]</em>, <em>instances=None</em>, <em>cos=0</em>, <em>packet_length=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1163-L1212"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.cs_set_replicas" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures a packet cloning session.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>session_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – clone session <em>id</em></li>
<li><strong>ports</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of port numbers to add to the clone session
(each port number is <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>instances</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of instances of the corresponding ports
(each instance is <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>cos</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – Class of Service (see <a class="reference external" href="https://p4.org/p4-spec/docs/PSA-v1.1.0.html#sec-after-ingress">here</a>)</li>
<li><strong>packet_lentgth</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – maximal packet length in bytes (after which, packets are truncated)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group. Instances can be explicitly assigned to ports by
passing the list instances to this function. If the list instances is not
specified, then the instance number is set to <code class="docutils literal"><span class="pre">0</span></code> for all the replicas by default.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">By default, the <code class="docutils literal"><span class="pre">packet_length</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code> i.e. no truncation happens and
<code class="docutils literal"><span class="pre">cos</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code> (normal packet classification). If <code class="docutils literal"><span class="pre">ports</span></code> is an empty
list, then the packets are not cloned to any port.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_enable">
<code class="descname">digest_enable</code><span class="sig-paren">(</span><em>digest_name</em>, <em>max_timeout_ns=0</em>, <em>max_list_size=1</em>, <em>ack_timeout_ns=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1248-L1287"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_enable" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables and configure the digests generation of the switch.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>digest_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the digest (the name is shown in the P4 runtime information file
generated by the compiler)</li>
<li><strong>max_timeout_ns</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the maximum server buffering delay in nanoseconds for an outstanding digest message</li>
<li><strong>max_list_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the maximum digest list size (in number of digest messages) sent by the server
to the client as a single <code class="docutils literal"><span class="pre">DigestList</span></code> Protobuf message</li>
<li><strong>ack_timeout_ns</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the timeout in nanoseconds that a server must wait for a digest list acknowledgement
from the client before new digest messages can be generated for the same learned data</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>By default, <code class="docutils literal"><span class="pre">max_timeout_ns</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code>, i.e. the server should generate a <code class="docutils literal"><span class="pre">DigestList</span></code>
message for every digest message generated by the data plane.</p>
<p>By default, <code class="docutils literal"><span class="pre">max_list_size</span></code> is set to <code class="docutils literal"><span class="pre">1</span></code>, i.e. the server should generate a <code class="docutils literal"><span class="pre">DigestList</span></code>
message for every digest message generated by the data plane.</p>
<p>By default, <code class="docutils literal"><span class="pre">ack_timeout_ns</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code>, i.e. the cache of digests not yet acknowledged must
always be an empty set.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">P4Runtime only supports named digests, i.e. those declared in P4 with the following syntax:
<code class="docutils literal"><span class="pre">digest&lt;named_struct_type&gt;(1,</span> <span class="pre">{struct_field_1,</span> <span class="pre">struct_field_2,</span> <span class="pre">...})</span></code> where <code class="docutils literal"><span class="pre">named_struct_type</span></code> must
be explicited and previously defined. The name of the digest for the configuration’s sake
is the name of the struct type (i.e. <code class="docutils literal"><span class="pre">named_struct_type</span></code>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_get_conf">
<code class="descname">digest_get_conf</code><span class="sig-paren">(</span><em>digest_name</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1330-L1361"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_get_conf" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables and configure the digests generation of the switch.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>digest_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the digest (the name is shown in the P4 runtime information file
generated by the compiler)</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal"><span class="pre">(max_timeout_ns,</span> <span class="pre">max_list_size,</span> <span class="pre">ack_timeout_ns)</span></code> where:<ul class="simple">
<li><code class="docutils literal"><span class="pre">max_timeout_ns</span></code> is the maximum server buffering delay in nanoseconds for an outstanding digest message;</li>
<li><code class="docutils literal"><span class="pre">max_list_size</span></code> is the maximum digest list size (in number of digest messages) sent by the server
to the client as a single DigestList Protobuf message;</li>
<li><code class="docutils literal"><span class="pre">ack_timeout_ns</span></code> is the timeout in nanoseconds that a server must wait for a digest list acknowledgement
from the client before new digest messages can be generated for the same learned data.</li>
</ul>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)">tuple</a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">P4Runtime only supports named digests, i.e. those declared in P4 with the following syntax:
<code class="docutils literal"><span class="pre">digest&lt;named_struct_type&gt;(1,</span> <span class="pre">{struct_field_1,</span> <span class="pre">struct_field_2,</span> <span class="pre">...})</span></code> where <code class="docutils literal"><span class="pre">named_struct_type</span></code> must
be explicited and previously defined. The name of the digest for the configuration’s sake
is the name of the struct type (i.e. <code class="docutils literal"><span class="pre">named_struct_type</span></code>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_set_conf">
<code class="descname">digest_set_conf</code><span class="sig-paren">(</span><em>digest_name</em>, <em>max_timeout_ns=0</em>, <em>max_list_size=1</em>, <em>ack_timeout_ns=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1289-L1328"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.digest_set_conf" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures the digests generation of the switch.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>digest_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the digest (the name is shown in the P4 runtime information file
generated by the compiler)</li>
<li><strong>max_timeout_ns</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the maximum server buffering delay in nanoseconds for an outstanding digest message</li>
<li><strong>max_list_size</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the maximum digest list size (in number of digest messages) sent by the server
to the client as a single <code class="docutils literal"><span class="pre">DigestList</span></code> Protobuf message</li>
<li><strong>ack_timeout_ns</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – the timeout in nanoseconds that a server must wait for a digest list acknowledgement
from the client before new digest messages can be generated for the same learned data</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>By default, <code class="docutils literal"><span class="pre">max_timeout_ns</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code>, i.e. the server should generate a <code class="docutils literal"><span class="pre">DigestList</span></code>
message for every digest message generated by the data plane.</p>
<p>By default, <code class="docutils literal"><span class="pre">max_list_size</span></code> is set to <code class="docutils literal"><span class="pre">1</span></code>, i.e. the server should generate a <code class="docutils literal"><span class="pre">DigestList</span></code>
message for every digest message generated by the data plane.</p>
<p>By default, <code class="docutils literal"><span class="pre">ack_timeout_ns</span></code> is set to <code class="docutils literal"><span class="pre">0</span></code>, i.e. the cache of digests not yet acknowledged must
always be an empty set.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">P4Runtime only supports named digests, i.e. those declared in P4 with the following syntax:
<code class="docutils literal"><span class="pre">digest&lt;named_struct_type&gt;(1,</span> <span class="pre">{struct_field_1,</span> <span class="pre">struct_field_2,</span> <span class="pre">...})</span></code> where <code class="docutils literal"><span class="pre">named_struct_type</span></code> must
be explicited and previously defined. The name of the digest for the configuration’s sake
is the name of the struct type (i.e. <code class="docutils literal"><span class="pre">named_struct_type</span></code>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_read">
<code class="descname">direct_counter_read</code><span class="sig-paren">(</span><em>direct_counter_name</em>, <em>match_keys</em>, <em>prio=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L518-L559"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_read" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads direct counter values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>direct_counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct counter</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>) used
to identify the entry</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match (used to identify the table
entry to which the direct counter is attached)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><p><code class="docutils literal"><span class="pre">(byte_count,</span> <span class="pre">packet_count)</span></code> where:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">byte_count</span></code> is the number of bytes counted;</li>
<li><code class="docutils literal"><span class="pre">packet_count</span></code> is the number of packets counted.</li>
</ul>
</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)">tuple</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">P4Runtime does not distinguish between the different counter types, i.e. counters are
always considered of <strong>PACKETS_AND_BYTES</strong> and both values are returned. It is user’s responsability
to use only the correct value (see <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-counterentry-directcounterentry">here</a>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_reset">
<code class="descname">direct_counter_reset</code><span class="sig-paren">(</span><em>direct_counter_name</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L609-L628"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets all the direct counters values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>direct_counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct counter</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_write">
<code class="descname">direct_counter_write</code><span class="sig-paren">(</span><em>direct_counter_name</em>, <em>match_keys</em>, <em>prio=0</em>, <em>pkts=0</em>, <em>byts=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L561-L607"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_counter_write" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes direct counter values. If no values are specified, the counter is reset.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>direct_counter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct counter</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>) used
to identify the entry</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match (used to identify the table
entry to which the direct counter is attached)</li>
<li><strong>pkts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of packets to write (default: 0)</li>
<li><strong>byts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of bytes to write (default: 0)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>There are three types of counters:</p>
<ul class="last simple">
<li><strong>BYTES</strong>, only the field <code class="docutils literal"><span class="pre">byts</span></code> is written and the value of <code class="docutils literal"><span class="pre">pkts</span></code> is ignored.</li>
<li><strong>PACKETS</strong>, only the field <code class="docutils literal"><span class="pre">pkts</span></code> is written and the value of <code class="docutils literal"><span class="pre">byts</span></code> is ignored.</li>
<li><strong>PACKETS_AND_BYTES</strong>, both <code class="docutils literal"><span class="pre">byts</span></code> and <code class="docutils literal"><span class="pre">pkts</span></code> are written.</li>
</ul>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_array_set_rates">
<code class="descname">direct_meter_array_set_rates</code><span class="sig-paren">(</span><em>direct_meter_name</em>, <em>rates</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L631-L666"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_array_set_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures rates for an entire direct meter array.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>direct_meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct meter</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code></li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_get_rates">
<code class="descname">direct_meter_get_rates</code><span class="sig-paren">(</span><em>direct_meter_name</em>, <em>match_keys</em>, <em>prio=0</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L724-L760"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_get_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieves rates for a direct meter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>direct_meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct meter</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)
used to identify the entry</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match (used to identify the table</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> if meter is configured, <strong>None</strong> otherwise</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)">list</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_set_rates">
<code class="descname">direct_meter_set_rates</code><span class="sig-paren">(</span><em>direct_meter_name</em>, <em>match_keys</em>, <em>prio=0</em>, <em>rates=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L668-L722"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.direct_meter_set_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures rates for a single direct meter entry.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>direct_meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the direct meter</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)
used to identify the entry</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match (used to identify the table
entry to which the direct meter is attached)</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> (default: None, i.e.
all packets are marked as green)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.get_digest_list">
<code class="descname">get_digest_list</code><span class="sig-paren">(</span><em>timeout=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L162-L178"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.get_digest_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieves <code class="docutils literal"><span class="pre">DigestList</span></code> and send back acknowledgment.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>timeout</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – time to wait for packet</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal"><span class="pre">DigestList</span></code> Protobuf Message or <strong>None</strong> if the timeout has expired and
no packet has been received.</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See <a class="reference external" href="https://github.com/p4lang/p4runtime/blob/45d1c7ce2aad5dae819e8bba2cd72640af189cfe/proto/p4/v1/p4runtime.proto#L543">here</a> for further details. If <code class="docutils literal"><span class="pre">timeout</span></code> is set to <strong>None</strong>, the
function will wait indefinitely.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_get_replicas">
<code class="descname">mc_get_replicas</code><span class="sig-paren">(</span><em>mgrp</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1058-L1094"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_get_replicas" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets replicas which belog to a multicast group.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mgrp</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – multicast group <em>id</em></td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal"><span class="pre">(ports,</span> <span class="pre">instances)</span></code> where:<ul class="simple">
<li><code class="docutils literal"><span class="pre">ports</span></code> is a list of port numbers of the multicast group;</li>
<li><code class="docutils literal"><span class="pre">instances</span></code> is list of instances of the corresponding ports.</li>
</ul>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)">tuple</a></td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group. Instances can be explicitly assigned to ports by
passing the list instances to this function. If the list instances is not
specified, then the instance number is set to <code class="docutils literal"><span class="pre">0</span></code> for all the replicas by default.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">mgrp</span></code> must be greater than <code class="docutils literal"><span class="pre">0</span></code>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_mgrp_create">
<code class="descname">mc_mgrp_create</code><span class="sig-paren">(</span><em>mgrp</em>, <em>ports=[]</em>, <em>instances=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L954-L995"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_mgrp_create" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates multicast group.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>mgrp</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – multicast group <em>id</em></li>
<li><strong>ports</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of port numbers to add to the multicast group
(each port number is a <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>instances</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of instances of the corresponding ports
(each instance is a <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group. Instances can be explicitly assigned to ports by
passing the list instances to this function. If the list instances is not
specified, then the instance number is set to <code class="docutils literal"><span class="pre">0</span></code> for all the replicas by default.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">mgrp</span></code> must be larger than <code class="docutils literal"><span class="pre">0</span></code>. If <code class="docutils literal"><span class="pre">ports</span></code> is an empty list,
then the packets are not multicasted to any port.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_mgrp_destroy">
<code class="descname">mc_mgrp_destroy</code><span class="sig-paren">(</span><em>mgrp</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L997-L1013"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_mgrp_destroy" title="Permalink to this definition">¶</a></dt>
<dd><p>Destroys multicast group.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mgrp</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – multicast group <em>id</em></td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">mgrp</span></code> must be larger than <code class="docutils literal"><span class="pre">0</span></code>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_set_replicas">
<code class="descname">mc_set_replicas</code><span class="sig-paren">(</span><em>mgrp</em>, <em>ports=[]</em>, <em>instances=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L1015-L1056"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.mc_set_replicas" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets replicas for multicast group.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>mgrp</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – multicast group <em>id</em></li>
<li><strong>ports</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of port numbers to add to the multicast group
(each port number is a <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
<li><strong>instances</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – list of instances of the corresponding ports
(each instance is a <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>A replica is logically a tuple <code class="docutils literal"><span class="pre">(port,</span> <span class="pre">instance)</span></code> which has to be unique
within the same multicast group. Instances can be explicitly assigned to ports by
passing the list instances to this function. If the list instances is not
specified, then the instance number is set to <code class="docutils literal"><span class="pre">0</span></code> for all the replicas by default.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">mgrp</span></code> must be larger than <code class="docutils literal"><span class="pre">0</span></code>. If <code class="docutils literal"><span class="pre">ports</span></code> is an empty list,
then the packets are not multicasted to any port.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_array_set_rates">
<code class="descname">meter_array_set_rates</code><span class="sig-paren">(</span><em>meter_name</em>, <em>rates</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L849-L884"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_array_set_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures rates for an entire meter array.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the meter</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code></li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_get_rates">
<code class="descname">meter_get_rates</code><span class="sig-paren">(</span><em>meter_name</em>, <em>index</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L928-L951"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_get_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieves rates for a meter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the meter</li>
<li><strong>index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – index of the meter to read (first element is at <code class="docutils literal"><span class="pre">0</span></code>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> if meter is configured, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)">list</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_set_rates">
<code class="descname">meter_set_rates</code><span class="sig-paren">(</span><em>meter_name</em>, <em>index</em>, <em>rates</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L886-L926"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.meter_set_rates" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures rates for a single  meter entry.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>meter_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the meter</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> (default: <strong>None</strong>, i.e.
all packets are marked as <strong>GREEN</strong>)</li>
<li><strong>index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – index of the meter to set (first element is at <code class="docutils literal"><span class="pre">0</span></code>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal"><span class="pre">cir</span></code> and <code class="docutils literal"><span class="pre">pir</span></code> use units/second, <code class="docutils literal"><span class="pre">cbursts</span></code> and <code class="docutils literal"><span class="pre">pburst</span></code> use units
where units is bytes or packets, depending on the meter type.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.parse_action_param">
<code class="descname">parse_action_param</code><span class="sig-paren">(</span><em>action_name</em>, <em>action_params</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L113-L117"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.parse_action_param" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.parse_match_key">
<code class="descname">parse_match_key</code><span class="sig-paren">(</span><em>table_name</em>, <em>key_fields</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L107-L111"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.parse_match_key" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.reset_state">
<code class="descname">reset_state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L119-L156"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.reset_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the gRPC server of switch by establishing a new <code class="docutils literal"><span class="pre">ForwardingPipelineConfig</span></code>.</p>
<p>For further details about this method, please check <a class="reference external" href="https://github.com/p4lang/p4runtime/blob/e9c0d196c4c2acd6f1bd3439f5b30b423ef90c95/proto/p4/v1/p4runtime.proto#L668">this</a>. Indeed,
this method sends to the server a <code class="docutils literal"><span class="pre">SetForwardingPipelineConfigRequest</span></code> with
action <code class="docutils literal"><span class="pre">VERIFY_AND_COMMIT</span></code>.</p>
<p>This method is buggy, please read the following warnings.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Due to some bug in the implementation of the gRPC server, this command
does not fully erase all the forwarding state of the switch, but only resets the
server.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>It is recommended to use <a class="reference internal" href="p4utils.utils.thrift_API.html#p4utils.utils.thrift_API.ThriftAPI.reset_state" title="p4utils.utils.thrift_API.ThriftAPI.reset_state"><code class="xref py py-meth docutils literal"><span class="pre">p4utils.utils.thrift_API.ThriftAPI.reset_state()</span></code></a>
to reset the forwarding states. Moreover, if you only use
the <a class="reference internal" href="p4utils.utils.thrift_API.html#p4utils.utils.thrift_API.ThriftAPI" title="p4utils.utils.thrift_API.ThriftAPI"><code class="xref py py-class docutils literal"><span class="pre">ThriftAPI</span></code></a> to reset the switch,
the gRPC server will not be reset.</li>
<li>To do things properly, both methods need to be called
(the one from <a class="reference internal" href="p4utils.utils.thrift_API.html#p4utils.utils.thrift_API.ThriftAPI" title="p4utils.utils.thrift_API.ThriftAPI"><code class="xref py py-class docutils literal"><span class="pre">ThriftAPI</span></code></a> and the one from
<a class="reference internal" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI" title="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI"><code class="xref py py-class docutils literal"><span class="pre">SimpleSwitchP4RuntimeAPI</span></code></a>).</li>
</ul>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_add">
<code class="descname">table_add</code><span class="sig-paren">(</span><em>table_name</em>, <em>action_name</em>, <em>match_keys</em>, <em>action_params=[]</em>, <em>prio=0</em>, <em>rates=None</em>, <em>pkts=None</em>, <em>byts=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L181-L297"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_add" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds entry to a match table.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</li>
<li><strong>action_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – action to execute on hit</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
<li><strong>action_params</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – parameters passed to action (each parameter is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> (if <strong>None</strong>, the meter
is set to its default behavior, i.e. marks
all packets as <strong>GREEN</strong>)</li>
<li><strong>pkts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of packets to write (if <strong>None</strong>, the count
is not changed)</li>
<li><strong>byts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of bytes to write (if <strong>None</strong>, the count
is not changed)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>There are different kinds of matches:</p>
<ul class="simple">
<li>For <em>exact</em> match: <code class="docutils literal"><span class="pre">&lt;value&gt;</span></code></li>
<li>For <em>ternary</em> match: <code class="docutils literal"><span class="pre">&lt;value&gt;&amp;&amp;&amp;&lt;mask&gt;</span></code></li>
<li>For <em>LPM</em> match: <code class="docutils literal"><span class="pre">&lt;value&gt;/&lt;mask&gt;</span></code></li>
<li>For <em>range</em> match: <code class="docutils literal"><span class="pre">&lt;start&gt;..&lt;end&gt;</span></code></li>
</ul>
<p>There are three types of <em>counters</em>:</p>
<ul class="simple">
<li><strong>BYTES</strong>, only the field <code class="docutils literal"><span class="pre">byts</span></code> is written and the value of <code class="docutils literal"><span class="pre">pkts</span></code> is ignored.</li>
<li><strong>PACKETS</strong>, only the field <code class="docutils literal"><span class="pre">pkts</span></code> is written and the value of <code class="docutils literal"><span class="pre">byts</span></code> is ignored.</li>
<li><strong>PACKETS_AND_BYTES</strong>, both <code class="docutils literal"><span class="pre">byts</span></code> and <code class="docutils literal"><span class="pre">pkts</span></code> are written.</li>
</ul>
<p>There are two types of <em>meters</em>:</p>
<ul class="simple">
<li><strong>BYTES</strong>, <code class="docutils literal"><span class="pre">rates</span></code> must be expressed in number of bytes per second.</li>
<li><strong>PACKETS</strong>, <code class="docutils literal"><span class="pre">rates</span></code> must be expressed in number of packets per second.</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>The <code class="docutils literal"><span class="pre">rates</span></code> field only applies if there is a direct meter attached
to the table.</li>
<li>The <code class="docutils literal"><span class="pre">pkts</span></code> and <code class="docutils literal"><span class="pre">byts</span></code> fields only apply if there is a direct counter
attached to the table.</li>
<li>The <code class="docutils literal"><span class="pre">prio</span></code> field must be set to a non-zero value if the match key includes
a ternary match or to zero otherwise.</li>
<li>A higher <code class="docutils literal"><span class="pre">prio</span></code> number indicates that the entry must be given higher
priority when performing a table lookup (see <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-table-entry">here</a> for details).</li>
</ul>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_clear">
<code class="descname">table_clear</code><span class="sig-paren">(</span><em>table_name</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L502-L515"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clears all entries in a match table (direct or indirect),
but not the default entry.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_delete_match">
<code class="descname">table_delete_match</code><span class="sig-paren">(</span><em>table_name</em>, <em>match_keys</em>, <em>prio=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L357-L385"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_delete_match" title="Permalink to this definition">¶</a></dt>
<dd><p>Deletes an existing entry in a table.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_modify_match">
<code class="descname">table_modify_match</code><span class="sig-paren">(</span><em>table_name</em>, <em>action_name</em>, <em>match_keys</em>, <em>action_params=[]</em>, <em>prio=0</em>, <em>rates=None</em>, <em>pkts=None</em>, <em>byts=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L387-L500"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_modify_match" title="Permalink to this definition">¶</a></dt>
<dd><p>Modifies entry in a table.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</li>
<li><strong>action_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – action to execute on hit</li>
<li><strong>match_keys</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – values to match (each value is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
<li><strong>action_params</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – parameters passed to action (each parameter is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
<li><strong>prio</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – priority in ternary match</li>
<li><strong>rates</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – <code class="docutils literal"><span class="pre">[(cir,</span> <span class="pre">cburst),</span> <span class="pre">(pir,</span> <span class="pre">pburst)]</span></code> (if <strong>None</strong>, the meter
is set to its default behavior, i.e. marks
all packets as <strong>GREEN</strong>)</li>
<li><strong>pkts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of packets to write (if <strong>None</strong>, the count
is not changed)</li>
<li><strong>byts</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a>) – number of bytes to write (if <strong>None</strong>, the count
is not changed)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<p>There are three types of <em>counters</em>:</p>
<ul class="simple">
<li><strong>BYTES</strong>, only the field <code class="docutils literal"><span class="pre">byts</span></code> is written and the value of <code class="docutils literal"><span class="pre">pkts</span></code> is ignored.</li>
<li><strong>PACKETS</strong>, only the field <code class="docutils literal"><span class="pre">pkts</span></code> is written and the value of <code class="docutils literal"><span class="pre">byts</span></code> is ignored.</li>
<li><strong>PACKETS_AND_BYTES</strong>, both <code class="docutils literal"><span class="pre">byts</span></code> and <code class="docutils literal"><span class="pre">pkts</span></code> are written.</li>
</ul>
<p>There are two types of <em>meters</em>:</p>
<ul class="simple">
<li><strong>BYTES</strong>, <code class="docutils literal"><span class="pre">rates</span></code> must be expressed in number of bytes per second.</li>
<li><strong>PACKETS</strong>, <code class="docutils literal"><span class="pre">rates</span></code> must be expressed in number of packets per second.</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>The <code class="docutils literal"><span class="pre">rates</span></code> field only applies if there is a direct meter attached
to the table.</li>
<li>The <code class="docutils literal"><span class="pre">pkts</span></code> and <code class="docutils literal"><span class="pre">byts</span></code> fields only apply if there is a direct counter
attached to the table.</li>
<li>When modifying the default entry, the configurations for its direct
resources will be reset to their defaults, according to <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-direct-resources">this</a>.</li>
<li>The <code class="docutils literal"><span class="pre">prio</span></code> field must be set to a non-zero value if the match key includes
a ternary match or to zero otherwise.</li>
<li>A higher <code class="docutils literal"><span class="pre">prio</span></code> number indicates that the entry must be given higher
priority when performing a table lookup (see <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-table-entry">here</a> for details).</li>
</ul>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_reset_default">
<code class="descname">table_reset_default</code><span class="sig-paren">(</span><em>table_name</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L336-L355"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_reset_default" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets default action for a match table.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When resetting the default entry, the configurations for
its direct resources will be reset to their defaults (see <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-default-entry">here</a>).</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_set_default">
<code class="descname">table_set_default</code><span class="sig-paren">(</span><em>table_name</em>, <em>action_name</em>, <em>action_params=[]</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L299-L334"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.table_set_default" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets default action for a match table.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>table_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – name of the table</li>
<li><strong>action_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – action to execute on hit</li>
<li><strong>action_params</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a>) – parameters passed to action
(each parameter is a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a>)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>True</strong> in case of success, <strong>None</strong> otherwise.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)">bool</a></p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When setting the default entry, the configurations for
its direct resources will be reset to their defaults, according to <a class="reference external" href="https://p4.org/p4runtime/spec/v1.3.0/P4Runtime-Spec.html#sec-direct-resources">this</a>.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">For the current implementation, the specification is not followed and
direct resources are not reset when modifying a table entry.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.teardown">
<code class="descname">teardown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L158-L160"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.SimpleSwitchP4RuntimeAPI.teardown" title="Permalink to this definition">¶</a></dt>
<dd><p>Tears down gRPC connection with the switch server.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="p4utils.utils.sswitch_p4runtime_API.handle_bad_input">
<code class="descclassname">p4utils.utils.sswitch_p4runtime_API.</code><code class="descname">handle_bad_input</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/nsg-ethz/p4-utils/tree/master/p4utils/utils/sswitch_p4runtime_API.py#L32-L44"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#p4utils.utils.sswitch_p4runtime_API.handle_bad_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Handles bad input.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>f</strong> (<a class="reference external" href="https://docs.python.org/3/library/types.html#types.FunctionType" title="(in Python v3.10)"><em>types.FunctionType</em></a>) – function or method to handle</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="p4utils.utils.monitor.html" class="btn btn-neutral float-left" title="p4utils.utils.monitor module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="p4utils.utils.sswitch_thrift_API.html" class="btn btn-neutral float-right" title="p4utils.utils.sswitch_thrift_API module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, Networked Systems Group (NSG@ETH).</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>